<?php
/*
 * [JINYUN!] (C)2001-2099 Jinyunweb.com
 * This is NOT a freeware, use is subject to license terms
 * $Id: 2017-12-13 03:39:35 apple $
*/
defined('BY_JYA') or exit('error');
$_RQ['op']=$_RQ['op']?$_RQ['op']:'list';
$return=array();
if($_RQ['op']=='list'){
	//搜索
	$params=array('uniacid'=>$_SESSION['uniacid']);
	if($_RQ['id']){
		$chatid=intval($_RQ['id']);
		$params['chatid']=$chatid;
	}
	if($_RQ['nickname']){
		$params['nickname like']='%'.trim($_RQ['nickname']).'%';
		$return['params']['nickname']=$_RQ['nickname'];
	}
	$fields=array('id','setmid','getmid','msg','createtime');
	$pindex = max(1, intval($_RQ['page']));
	$psize = 15;
	$total='';
	$list=pdo_getslice('jy_ailiao_tcplog',$params,array($pindex,$psize),$total,$fields);
	if($list){
		foreach($list as &$row){
			$member=pdo_get('jy_ailiao_member',array('mid'=>$row['setmid']));
			$row['logo']=$member['logo'];
			$row['name']=$member['name'];
			$row['createtime']=date('20y/m/d H:i:s',$row['createtime']);
		}
	}
	$return['list']=$list?$list:array();
	$totalpage=ceil($total/$psize);
	$totalpage=intval($totalpage);
	$return['totalpage'] =$totalpage;
	$return['params']['page'] =$pindex;
	$htmls=array(
		'type'=>'list',
		'tabs'=>array(
			'0'=>array('op'=>'list','title'=>'会话消息'),
		),
		'list'=>array('data'=>'list','edit'=>false,'list'=>array(
				array('name'=>'logo','title'=>'头像','type'=>'image'),
				array('name'=>'name','title'=>'昵称','type'=>'string'),
				array('name'=>'createtime','title'=>'时间','type'=>'string'),
			),'action'=>array(
				array('type'=>'modal','op'=>'detail','title'=>'详情'),
			)
		),
		'search_one'=>array('name'=>'nickname','add'=>false)
	);
	$return['htmls']=$htmls;
	exi($return);
}
if($_RQ['op']=='detail'){
	$id=intval($_RQ['id']);
	if($id){
		$item=pdo_get('jy_ailiao_tcplog',array('uniacid'=>$_SESSION['uniacid'],'id'=>$id));
	}else{
		exi('没获取到会话！','error');
	}
	$return['item']=$item;
	$htmls=array(
		'type'=>'look',
		'desc'=>'消息详情',
		'look'=>array(
			array('type'=>'text','title'=>'消息内容','name'=>'msg','help'=>'' ),
		)
	);
	$return['htmls']=$htmls;
	exi($return);
}
?>